<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订货单记录列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>入库单编号：</p>
                            <input type="text" name="purStoId"/>
                        </li>
                        <li>
                            <p>总金额：</p>
                            <input type="text" name="purMoney"/>
                        </li>
                        <li class="select-time">
                            <p>时间：</p>
                            <input type="text" class="time-input" id="startTime" placeholder="时间"
                                   name="params[beginPurSubmittime]"/>
                            <!--<span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endDhSubmittime]"/>-->
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var removeFlag = [[${@permission.hasPermi('essentials:purchase:remove')}]];
    var details = [[${@permission.hasPermi('essentials:details:view')}]];
    var prefix = ctx + "essentials/storage";

    $(function () {
        var options = {
            url: prefix + "/pursto/list",
            modalName: "订货单记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'purId',
                    title: '订单id',
                    visible: true
                },
                {
                    field: 'purStoId',
                    title: '入库单编号'
                },
                {
                    field: 'purMoney',
                    title: '总金额'
                },
                {
                    field: 'purSubmittime',
                    title: '时间'
                },
                {
                    field: 'purStatus',
                    title: '状态'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-rounded btn-sm ' + details + '" href="/essentials/details?id=' + row.purId + '"><i class="fa fa-search"></i>查看详情</a>');
                        actions.push('<a class="btn btn-primary btn-rounded btn-sm ' + details + '" href="javascript:sub('+row.purId+')"><i class="fa fa-coffee"></i>确认入库</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function sub(id) {
        $.ajax({
            type:"post",
            url:"/essentials/storage/stofinish",
            data:{purId:id},
            success:function(data){
                if(data){
                    $.modal.msg("入库成功！", modal_status.SUCCESS);
                    $.table.search();
                }else{
                    $.modal.msg("入库失败！",modal_status.FAIL);
                }
            },
            error:function (data) {
                $.modal.msg("入库失败！",modal_status.FAIL);
            }
        })
    }
</script>
</body>
</html>